import { onMounted, reactive,ref } from "vue"
import axios from 'axios'
import {mainStore} from '../store'

interface userInfo{
    avatarUrl:string,
    city:string,
    gender:number,
    language:string,
    nickName:string,
    province:string
}

const store = mainStore()

export let userInfo1 = reactive<userInfo>({
    avatarUrl: '' as string,
    city: '' as string,
    gender: 0 as number,
    language: '' as string,
    nickName: '' as string,
    province: '' as string
})

export function getUserInfo(){
    uni.getUserProfile({
        desc: '获取用户信息',
        success: (response)=>{
            console.log(response)
            // userInfo1.avatarUrl = response.userInfo.avatarUrl
            // userInfo1.nickName = response.userInfo.nickName
            store.$state.userInfo.avatarUrl = response.userInfo.avatarUrl
            store.$state.userInfo.nickName = response.userInfo.nickName
        },
        fail: (err)=>{
            console.log(err)
        }
    })
}

export function goToUserMeg(){
    uni.redirectTo({
        url: '../userMessage/userMessage'
    })
}


